# Maintainer: Philipp Smirnov https://github.com/sad-poet

_realname=templates-parser
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=25.0.0
pkgrel=2
pkgdesc="Ada tools to create templated text streams, such as dynamic HTML documents (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64')
url="https://github.com/AdaCore/templates-parser"
msys2_references=(
  'aur: templates_parser'
  'gentoo: dev-ada/templates-parser'
)
license=('spdx:GPL-3.0-or-later WITH GCC-exception-3.1')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-gcc-ada")
makedepends=("${MINGW_PACKAGE_PREFIX}-gprbuild")
source=("https://github.com/AdaCore/templates-parser/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('03cd620c658aee3c2d69be0a8369e45666dc51d25d3cb580b77c4ad471446041')

build() {
  [[ -d "${srcdir}"/build-${MSYSTEM} ]] && rm -rf "${srcdir}"/build-${MSYSTEM}
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}"/build-${MSYSTEM}
  cd "${srcdir}"/build-${MSYSTEM}

  make DEFAULT_LIBRARY_TYPE=relocatable prefix="${MINGW_PREFIX}" setup

  make
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}

  make -j1 install DESTDIR="${pkgdir}" prefix="${MINGW_PREFIX}"

  install -Dm644 -t "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname} \
    "${srcdir}"/${_realname}-${pkgver}/COPYING*
}
